<template>
  <div class="playerWeapon" :class="{ pick: pick }">
    <img :src="weapon.img" class="img" />
    <div class="name">{{ weapon.name }}</div>
    <div class="count" v-show="count > 1">{{ count }}</div>
  </div>
</template>

<script>
import { getWeaponById } from "@/util/weapon.js";

export default {
  props: {
    id: {
      type: Number,
      required: true,
    },
    count: {
      type: Number,
      required: true,
    },
    pick: {
      type: Boolean,
      required: true,
    },
  },
  computed: {
    weapon() {
      return getWeaponById(this.id);
    },
  },
};
</script>

<style scoped>
.playerWeapon {
  position: relative;
  box-sizing: border-box;
  width: 80px;
  height: 80px;
  background-color: rgb(60, 60, 60);
  border-radius: 10px;
  padding: 20px;
  border: 3px solid rgb(80, 80, 80);
}
.playerWeapon.pick {
  border: 3px solid rgb(255, 255, 255);
}
.img {
  position: relative;
  width: 100%;
  height: 100%;
}
.name {
  position: absolute;
  width: auto;
  height: 20px;
  line-height: 20px;
  font-size: 12px;
  left: 0;
  bottom: 0;
  padding: 1px 5px;
  border-radius: 8px;
  background-color: rgba(255, 255, 255, 0.8);
}
.count {
  position: absolute;
  width: auto;
  height: 16px;
  line-height: 16px;
  font-size: 12px;
  right: 0;
  top: 0;
  padding: 2px 5px;
  border-radius: 8px;
  background-color: rgba(255, 255, 255, 0.8);
}
</style>